<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" isELIgnored="false"%>
<%String path = request.getContextPath() ;%>
<%
	String regionShowSecUseLvl = request.getParameter("regionSecUseShowLvl");
	if(regionShowSecUseLvl==null){
		regionShowSecUseLvl="3";//未设置显示级别 默认设置为3级(即省.市.县/区)
	}
%>

			<input name="rgnProvCdSecUse" id="rgnProvCdSecUse" data-value=" " placeholder="--请选择--" ltype="combobox" onchange="clearRegionCitySecUse()">
			<span id="rgnProvCdSpan" class="requiredSymbol" style="display: none">*</span>
			<input name="rgnCityCdSecUse" id="rgnCityCdSecUse" data-value=" " placeholder="--请选择--" ltype="combobox" onchange="clearRegionCountySecUse()">
			<span id="rgnCityCdSpan" class="requiredSymbol" style="display: none">*</span>
			<input name="rgnCountyCdSecUse" id="rgnCountyCdSecUse" data-value=" " placeholder="--请选择--" ltype="combobox">
			<span id="rgnCountyCdSpanSecUse" class="requiredSymbol" style="display: none">*</span>
	
			<input type="hidden" id="regionShowSecUseLvl" value="<%=regionShowSecUseLvl %>"/>
<script type="text/javascript">
var _regionSecUseShowLvl=$("#regionShowSecUseLvl").val();
//修改时数据初始值
var _rgnProvCdSecUseUpdataValue = "",//省
    _rgnCityCdSecUseUpdataValue = "",//市
    _rgnCountySecUseUpdataValue = "";//县/区
    
$(function(){
	$("#rgnProvCdSecUse").ligerComboBox({
		valueField: 'key',
		textField: 'value',
		width:150,
		onChangeValue:function(value){
			if(value){
				initRegionCitySecUseSelectData(value);
			}else{
				var citySelectObj = liger.get("rgnCityCdSecUse");
				citySelectObj.selectValue(" ");
			}
		}
	});
	$("#rgnCityCdSecUse").ligerComboBox({
		valueField: 'key',
		textField: 'value',
		width:150,
		onChangeValue:function(value){
			if(value){
				initCountySecUseSelectData(value);
			}else{
				var countySelectObj = liger.get("rgnCountyCdSecUse");
				countySelectObj.selectValue(" ");
			}
		}
	});
	$("#rgnCountyCdSecUse").ligerComboBox({
		valueField: 'key',
		textField: 'value',
		width:150
	});
	
	//判断regionShowLvl参数  1:省   2:省市   3:省市县
	if(_regionSecUseShowLvl==1){
		$("#rgnCityCdSecUse").parents(".l-text-wrapper").remove();
		$("#rgnCountyCdSecUse").parents(".l-text-wrapper").remove();
	}else if(_regionSecUseShowLvl==2){
		$("#rgnCountyCdSecUse").parents(".l-text-wrapper").remove();
	}
	
	initRegionProvSecUseSelectData();
	
});
	//初始化省级数据
	function initRegionProvSecUseSelectData(){
		$.ajax({
			type: 'post',
			dataType:'json',
			url: '<%=path%>/system/sysRegion/getProvinceRegion.do',
			success:function(msg){
				 if(msg.success == 1){
					 var provSelectObj = liger.get("rgnProvCdSecUse");
					 provSelectObj.setData(msg.data);
					 if(StringUtils.isNotEmpty(_rgnProvCdSecUseUpdataValue)){
						 provSelectObj.selectValue(_rgnProvCdSecUseUpdataValue);
					 }else{
						 //provSelectObj.selectValue(msg.data[0].key);
					 }
				 }else{
					 $.ligerDialog.SQalert({content:msg.info, SQ_type: "error"});
				 }
			}
		});
	}

	//初始化市级数据(value:省代码)
	function initRegionCitySecUseSelectData(value){
		if(!$("#rgnCityCdSecUse").length)return;
		var provSelectObj = liger.get("rgnProvCdSecUse");
		var _provCd = provSelectObj.findValueByText(value);
		if(!_provCd){
			return;
		}
		$.ajax({
			type: 'post',
			dataType:'json',
			data:{rgnCd:_provCd},
			url: '<%=path%>/system/sysRegion/getRegionByRgnCd.do',
			success:function(msg){
				 if(msg.success == 1){
					 var citySelectObj = liger.get("rgnCityCdSecUse");
					 if(msg.data){
						 citySelectObj.setData(msg.data);
						 if(StringUtils.isNotEmpty(_rgnCityCdSecUseUpdataValue)){
							 citySelectObj.selectValue(_rgnCityCdSecUseUpdataValue);
						 }else{
							 //citySelectObj.selectValue(msg.data[0].key);
						 }
					 }else{
						 citySelectObj.clear();
						 citySelectObj.setData({});//置空下拉框数据
						 var countySelectObj = liger.get("rgnCountyCdSecUse");
						 if(countySelectObj){
							 countySelectObj.clear();
							 countySelectObj.setData({});//置空下拉框数据
						 }
					 }
				 }else{
					 $.ligerDialog.SQalert({content:msg.info, SQ_type: "error"});
				 }
			}
		});
	}
	
	//初始化县/区数据(value:市代码)
	function initCountySecUseSelectData(value){
		if(!$("#rgnCountyCdSecUse").length)return;
		var citySelectObj = liger.get("rgnCityCdSecUse");
		var _cityCd = citySelectObj.findValueByText(value);
		if(!_cityCd){
			return;
		}
		$.ajax({
			type: 'post',
			dataType:'json',
			data:{rgnCd:_cityCd},
			url: '<%=path%>/system/sysRegion/getRegionByRgnCd.do',
			success:function(msg){
				 if(msg.success == 1){
					 var countySelectObj = liger.get("rgnCountyCdSecUse");
					 if(msg.data){
						 countySelectObj.setData(msg.data);
						 if(StringUtils.isNotEmpty(_rgnCountySecUseUpdataValue)){
							 countySelectObj.selectValue(_rgnCountySecUseUpdataValue);
						 }else{
							 //countySelectObj.selectValue(msg.data[0].key);
						 }
					 }else{
						 countySelectObj.clear();
						 countySelectObj.setData({});//置空下拉框数据
					 }
				 }else{
					 $.ligerDialog.SQalert({content:msg.info, SQ_type: "error"});
				 }
			}
		});
	}
	
	//页面调用者可根据以下方法设置修改时的数据初始值
	function setRgnProvCdSecUseUpdataValue(value){//省
		_rgnProvCdSecUseUpdataValue = value;
	}
	function setRgnCityCdSecUseUpdataValue(value){//市
		_rgnCityCdSecUseUpdataValue = value;
	}
	function setRgnCountyCdSecUseUpdataValue(value){//县/区
		_rgnCountySecUseUpdataValue = value;
	}
	//修改时设置数据初始值之后需要调用的事件
	function setRegionSelectDataChangeSecUse(){
		var provSelectObj = liger.get("rgnProvCdSecUse");
		provSelectObj.selectValue(_rgnProvCdSecUseUpdataValue);
	}

	//获取区域下拉框选中值
	function getRgnProvCdSecUse(){ //省
		var provSelectObj = liger.get("rgnProvCdSecUse");
		var _provCd = provSelectObj.getValue();
		return _provCd;
	}
	function getRgnCityCdSecUse(){ //市
		var citySelectObj = liger.get("rgnCityCdSecUse");
		var _cityCd = citySelectObj.getValue();
		return _cityCd;
	}
	function getRgnCountyCdSecUse(){ //县/区
		var countySelectObj = liger.get("rgnCountyCdSecUse");
		var _countyCd = countySelectObj.getValue();
		return _countyCd;
	}
	
	//禁用省
	function disabledRgnProvCdSecUse(){
		liger.get("rgnProvCdSecUse").setDisabled(true);
	}
	//禁用市
	function disabledRgnCityCdSecUse(){
		liger.get("rgnCityCdSecUse").setDisabled(true);
	}
	//禁用县
	function disabledRgnCountyCdSecUse(){
		liger.get("rgnCountyCdSecUse").setDisabled(true);
	}
	
	//清除选中状态
	function clearRegionSelectStatusSecUse(){
		var rgnProvCdObj = liger.get("rgnProvCdSecUse");
		rgnProvCdObj.selectValue(" ");
		var rgnCityCdObj = liger.get("rgnCityCdSecUse");
		rgnCityCdObj.selectValue(" ");
		var rgnCountyCdObj = liger.get("rgnCountyCdSecUse");
		rgnCountyCdObj.selectValue(" ");
	}
	
	//设置省必填校验(参数:from表单ID)
	function valitadeRgnProvCdSecUse(formNm){
		var formSet1=liger.get(formNm);
		formSet1.setFieldValidate("rgnProvCdSecUse", {
	        required: true,
	        select: true
	    });
		$("#rgnProvCdSecUseSpan").show();
	}
	//设置市必填校验(参数:from表单ID)
	function valitadeRgnCityCdSecUse(formNm){
		var formSet1=liger.get(formNm);
		formSet1.setFieldValidate("rgnCityCdSecUse", {
	        required: true,
	        select: true
	    });
		$("#rgnCityCdSpanSecUse").show();
	}
	//设置县必填校验(参数:from表单ID)
	function valitadeRgnCountyCdSecUse(formNm){
		var formSet1=liger.get(formNm);
		formSet1.setFieldValidate("rgnCountyCdSecUse", {
	        required: true,
	        select: true
	    });
		$("#rgnCountyCdSpanSecUse").show();
	}

//清除状态 市
function clearRegionCitySecUse(){
    var provSelectObj = liger.get("rgnProvCdSecUse");
    var _provCd = provSelectObj.getValue();
    if (_provCd != _rgnProvCdSecUseUpdataValue) {
        _rgnCityCdSecUseUpdataValue = null;
    }
}

//清除状态 县/区
function clearRegionCountySecUse(){
    var citySelectObj = liger.get("rgnCityCdSecUse");
    var _cityCd = citySelectObj.getValue();
    if (_cityCd != _rgnCityCdSecUseUpdataValue) {
        _rgnCountySecUseUpdataValue = null;
    }
}
	
	
</script>

